package com.linjiahao.servicebase.exception;


import com.linjiahao.servicebase.commo.ResultMap;
import com.linjiahao.servicebase.commo.online_education_Exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultMap error(Exception e){
        log.error(e.getMessage());
        return ResultMap.error();
    }

    @ExceptionHandler(online_education_Exception.class)
    @ResponseBody
    public ResultMap error(online_education_Exception e){
        e.printStackTrace();
        return ResultMap.error().message(e.getMsg()).code(e.getCode());
    }
}
